$(function () {
    obj.init();
});

var obj = new function() {
    return {
        img: '',
        init: function () {
            this.funObj().addData();
            this.listener();
        },
        listener: function () {
            var $this = this;
            $('#teacher').on('change',function () {
                $this.funObj().addTeacherName();
            });
        },
        funObj: function () {
            var $this = this;
            return {
                addData: function () {
                    $('#teacher').select2({placeholder: '请选择', width: 100});
                },
                addTeacherName: function () {
                    var teaObj = $('#teacher');
                    var teachId = teaObj.val();
                    var teacherName = teaObj.find("option:selected").text();
                    $('#checkTeacher').html(teacherName);
                    xhExtra.ajaxRequest('res/getCheckTypeInQR', {id: id, teachId: teachId}, {check: true}, function(image) {
                        if (image.msg) {
                            var img = '<img src="' + image.msg + '" width="45%">';
                            $('#img').html(img);
                            $('#showNotic').html('（注：仅被选择的老师可扫码确认）');
                        }
                    });
                }
            }
        }
    }
};
